package com.qianfeng.strategy.feign;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
import java.util.Set;

@FeignClient(value = "smsplatform-cache", fallback = CacheServiceFallback.class)
public interface CacheService {
    @RequestMapping(value = "/cache/get/{key}", method = RequestMethod.GET)
    String get(@PathVariable("key") String key);

    @RequestMapping(value = "/cache/getobject/{key}", method = RequestMethod.GET)
    Object getObject(@PathVariable("key") String key);

    @RequestMapping(value = "/cache/delete", method = RequestMethod.POST)
    boolean del(@RequestParam("keys") String... keys);

    @RequestMapping(value = "/cache/hmset/{key}", method = RequestMethod.POST)
    void hmset(@PathVariable("key") String key, @RequestBody Map map);

    @RequestMapping(value = "/cache/hmget/{key}", method = RequestMethod.GET)
    public Map hmget(@PathVariable("key") String key);

    @RequestMapping(value = "/cache/save2cachewithexpire", method = RequestMethod.POST)
    void set(@RequestParam("key") String key, @RequestParam("value") String value, @RequestParam("expireSecond") Long expireSecond);

    @RequestMapping(value = "/cache/save2cache/{key}/{value}", method = RequestMethod.POST)
    void saveCache(@PathVariable("key") String key, @PathVariable("value") String value);

    @RequestMapping(value = "/cache/incr", method = RequestMethod.GET)
    public Long incr(@RequestParam("key") String key, @RequestParam("delta") long value);

    @PostMapping("/cache/pipel")
    List<Object> pipelineOps(@RequestBody Map<String, Object> map);

    @PostMapping("/cache/add2set")
    public  Long add2Set(@RequestParam("key") String key, @RequestParam("members") List<String> members);

    @GetMapping("/cache/members/{key}")
    public Set<String> members(@PathVariable String key) ;

    @GetMapping("/cache/ismember/{key}/{member}")
    public Boolean isMember(@PathVariable String key, @PathVariable String member) ;


    @PostMapping("/cache/update")
    public Long update(@RequestParam("key") String key,@RequestParam("beginMember") String beginMember,@RequestParam("endMember") String endMember);


    @PostMapping("/cache/deletes")
    public Long delete(@RequestParam("key") String key,@RequestParam("members") String ...members);
}
